package com.zpark.signup.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zpark.signup.validate.ValidatedGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;

/**
 * 用户表
 *
 * @TableName user
 */
@TableName(value = "user")
@Data
@ApiModel(value = "User对象", description = "用户")
@EqualsAndHashCode
public class User implements Serializable {
    /**
     * 用户ID
     */
    @ApiModelProperty(value = "用户ID")
    @TableId(type = IdType.AUTO)
    @NotNull(message = "id不能为空", groups = ValidatedGroup.UPDATE.class)
    private Integer id;

    /**
     * 用户身份证
     */
    @Size(min = 18, max = 18, groups = {ValidatedGroup.CREATE.class})
    @Pattern(regexp = "^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$", groups = {ValidatedGroup.CREATE.class})
    @ApiModelProperty("用户身份证")
    private String identity;

    /**
     * 用户名
     */
    @NotNull(message = "用户名不能为空", groups = {ValidatedGroup.CREATE.class})
    @Pattern(regexp = "^[\\u4e00-\\u9fa5a-zA-Z0-9]{3,12}$", groups = {ValidatedGroup.CREATE.class})
    @ApiModelProperty("用户名")
    private String username;

    /**
     * 性别
     */
    @ApiModelProperty("性别")
    private String sex;

    /**
     * 密码
     */
    @NotNull(message = "密码不能为空", groups = {ValidatedGroup.CREATE.class})
    @Pattern(regexp = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[\\s\\S]{6,18}$", groups = {ValidatedGroup.CREATE.class})
    @ApiModelProperty("密码")
    private String password;

    /**
     * 邮箱
     */
    @Email(groups = {ValidatedGroup.CREATE.class})
    @ApiModelProperty("邮箱")
    private String email;

    /**
     *
     */
    @ApiModelProperty("班级id")
    private Integer clazzId;

    /**
     * 电话
     */
    @ApiModelProperty("电话")
    private String phone;

    /**
     * 用户状态：0：禁用；1：启用
     */
    @ApiModelProperty("用户状态：0：禁用；1：启用")
    private Integer status;

    /**
     * 创建时间
     */
    @ApiModelProperty("创建时间")
    private Date createdTime;

    /**
     * 更新时间
     */
    @ApiModelProperty("更新时间")
    private Date updateTime;

    /**
     * 备注
     */
    @ApiModelProperty("备注")
    private String remark;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;


}